package rules.tree;


import org.jdom.Element;

public class Head {
	private Element head;
        private Atom a;
	//private ArrayList<String> list;
	
	public Head(Element head){
		this.head = head;
                this.a = (Atom) getAtom((Element) head.getChildren().get(0));
	}

        public Head(){
            head = new Element("head");
        }

	public Element getElement(){
		return head;
	}
	
	private static Atom getAtom(Element e){
                Atom atom = new Atom(e);
		String type = atom.getTypeAtom();
		if (type.equals("classAtom"))
			return atom.getClassAtom();
		else if (type.equals("propertyAtom"))
			return atom.getPropertyAtom();
		else if (type.equals("builtinAtom"))
			return atom.getBuiltinAtom();
		return null;     
	}

        public Atom getAtom(){
            return a;
        }

         public void setAtom(Atom a){
            this.a=a;
            head.addContent(a.getElement());
        }

        /*verificar se o metodo acima pode ser substituido por...
         public Atom getAtom(){
            return a;
        }*/
	
        /*acho que faz mais sentido como metodo de atom... verificar!
	public String getVar(){
		Object o = this.getAtom();
		String var = null;
		if(o instanceof ClassAtom)
			var = ((ClassAtom) o).getVar().print();
		return var;
	}*/
}
